﻿using System;
using System.Collections.Generic;

namespace BSharp.Compiler.Emit
{
	public class FunctionCompilationUnit : CompilationUnit
	{
		public readonly string Name;

		private IEnumerable<IntermediateInstruction> instructions;

		public FunctionCompilationUnit (IEnumerable<IntermediateInstruction> instructions)
		{
			this.instructions = instructions;
		}

		public override void CompileUnit (IntermediateCompiler compiler)
		{
			foreach (IntermediateInstruction instruction in instructions) {
				instruction.Visit (compiler);
			}
		}

		public void DebugShowDisassembly ()
		{
			foreach (IntermediateInstruction ins in instructions) {
				Console.WriteLine (ins.ToString ());
			}
		}
	}
}

